#ifndef _PRIMES_KERNEL_H_
#define _PRIMES_KERNEL_H_

#include <stdio.h>


__device__ bool isPrime(int num) 
{
	int divisor = 2;

	if(num < 2)
		return false;
	if(num == 2)
		return true;

	while((divisor * divisor) <= num) 
	{
		if(num % divisor == 0)
			return false;
		divisor++;
	}

	return true;
}

__global__ void findPrimes_kernel(int *arr) 
{
	int element = threadIdx.x;
	
	if(!isPrime(arr[element])) 
	{
		arr[element] = -1;
	}
}

#endif
